package com.human;

import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

@SpringBootApplication
@ServletComponentScan
@MapperScan("com.human.dao")
public class Application {

    @Autowired
    private DataSource dataSource;

    @Bean
    public CommandLineRunner commandLineRunner() {
        return args -> {
            // 检查Druid数据源是否成功注入
            System.out.println(dataSource.getClass().getName());
        };
    }

    public static void main(String[] args) {
        SpringApplication.run(Application.class);
        Logger logger = LoggerFactory.getLogger(Application.class);
        logger.info("项目启动");
    }

}
